package com.woke.adapter;

import android.annotation.SuppressLint;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.woke.data.Datas_fenrun;
import com.zhongcai.online.R;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class Myfenrunadapter extends BaseAdapter{
	private LayoutInflater mInflater;
	private List<Datas_fenrun> datalist;
	
	public Myfenrunadapter(LayoutInflater minflater, ArrayList<Datas_fenrun> datalist) {
		this.mInflater = minflater;
		this.datalist = datalist;
	}

	class Holder {
		TextView user_nicename;
		TextView user_type;
		TextView money;
		TextView create_time;
		
	
	}

	
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return datalist.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@SuppressLint("SimpleDateFormat")
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		Holder holder = null;
		if(convertView == null){
			holder = new Holder();
			convertView = mInflater.inflate(R.layout.layout_include_line3, null);
			holder.user_nicename = (TextView) convertView.findViewById(R.id.include_fenrun);
			holder.user_type = (TextView) convertView.findViewById(R.id.include_fenrun2);
			holder.money = (TextView) convertView.findViewById(R.id.include_fenrun3);
			holder.create_time = (TextView) convertView.findViewById(R.id.include_fenrun4);

			convertView.setTag(holder);
		}else{
			 holder = (Holder) convertView.getTag();
		}
		Datas_fenrun data = datalist.get(position);
		holder.user_nicename.setText(data.getUser_nicename());
		
		if(data.getUser_type().equals("2")){
			holder.user_type.setText("铜牌会员");
		}else if(data.getUser_type().equals("3")){
			holder.user_type.setText("银牌会员");
		}else if(data.getUser_type().equals("4")){
			holder.user_type.setText("金牌会员");
		}
		holder.money.setText(data.getMoney());
		holder.create_time.setText(times(data.getCreate_time()));
		return convertView;
	}
	@SuppressLint("SimpleDateFormat")
	public String times(String time) {
		SimpleDateFormat sdr = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		@SuppressWarnings("unused")
		long lcc = Long.valueOf(time);
		int i = Integer.parseInt(time);
		String times = sdr.format(new Date(i * 1000L));
		return times;

	}

}
